<template>
	<view>
		<view 
		class="text-center toptitle">
			一言
		</view>
		<!-- 头像框 -->
		<view class="margin-xl text-center">
			<image 
			class="cu-avatar xl round" 
			src="../../static/img/yiyan.png" mode="aspectFill"></image>
			<view class="margin-lg">登录账号</view>
		</view>
		<!-- 账号 -->
		<view class="padding">
			<custom-input v-model="username" icon="cuIcon-people" holder="请输入账号">	
			</custom-input>
		</view>
		<!-- 密码 -->
		<view class="padding">
			<custom-input
			type="password"
			 v-model="passward" icon="cuIcon-lock" holder="请输入密码">
			</custom-input>
		</view>
		
		<!-- 按钮 -->
		<view class="flex justify-between padding-xl align-center bt">
			<button @click="handleLogin" class="cu-btn bnt1">登录</button>
			<view class="">还没有账号？</view>
			<button @click="handleRegister" class="cu-btn bnt2">注册</button>
		</view>
	</view>
</template>

<script setup lang="ts">
import { ref, type Ref } from 'vue';
import {useCounterStore} from'../../store/counter'
import { onBackPress, onLoad } from '@dcloudio/uni-app';
const counter=useCounterStore()
console.log('昵称',counter.userData);
//账号/密码
const username:Ref<string>=ref('')
const passward:Ref<string>=ref('')
//转注册页面
const handleRegister=()=>{
	uni.navigateTo({
		url:'/pages/mine/register'
	})
}
//登录功能
const handleLogin=async()=>{
	let res= counter.loginUser(username.value,passward.value)
	console.log('111',res);
	
}
//退出监听
onBackPress(()=>{
	 console.log('监听到返回事件')
	  // 返回true阻止默认返回行为
	  return true
})
 
</script>

<style lang="scss">
page{
	background-color: #666;
	background-image: url("../../static/img/bacround.png");
	background-blend-mode: overlay; /* 纹理与底色混合 */
}
.bt{
	margin-top: 300rpx;
	button{
		width: 30%;
	}
	.bnt1{
		color: #eeeeee;
		background-color: #444444;
		 opacity: 0.8
	}
	.bnt2{
		background-color: #777777;
	}
}  
.toptitle{
	font-size: 50px; 
	margin: 20rpx 0 100rpx;
}  

</style>
